home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / extra / pro13 / ftally.c < prev    next >
C/C++ Source or Header  |  1993-08-28  |  3KB  |  175 lines

  1. /*
  2.     ftally.C
  3.  
  4.     Version 1.5
  5.  
  6.     Tally all files matching the user-specified filespec.
  7.  
  8.     Copyright (C) 1993, Geoff Friesen B.Sc.
  9.     All rights reserved.
  10.  
  11.     Developed with: Borland C++ 3.1
  12. */
  13.  
  14. /*
  15.     set ti=c:\borlandc\tsr\tsrlib
  16.     t ftally -hf -i
  17. */
  18.  
  19. #if !defined(__TINY__)
  20. #error Tiny Memory Model Expected
  21. #endif
  22.  
  23. #include "tsrlib.H"
  24.  
  25. char *title = "\r\n"
  26.  
  27. "╔═════════════════════════════════════════════════╗\r\n"
  28. "║ ▒▒▒▒▒ ▒▒▒▒▒   ▒   ▒     ▒     ▒   ▒             ║\r\n"
  29. "║ ▒       ▒    ▒ ▒  ▒     ▒     ▒   ▒             ║\r\n"
  30. "║ ▒       ▒   ▒   ▒ ▒     ▒     ▒   ▒             ║\r\n"
  31. "║ ▒▒▒▒    ▒   ▒▒▒▒▒ ▒     ▒      ▒▒▒  Version 1.5 ║\r\n"
  32. "║ ▒       ▒   ▒   ▒ ▒     ▒       ▒               ║\r\n"
  33. "║ ▒       ▒   ▒   ▒ ▒     ▒       ▒               ║\r\n"
  34. "║ ▒       ▒   ▒   ▒ ▒▒▒▒▒ ▒▒▒▒▒   ▒               ║\r\n"
  35. "║                                                 ║\r\n"
  36. "║ Copyright (C) 1993, Geoff Friesen B.Sc.         ║\r\n"
  37. "║ All rights reserved.                            ║\r\n"
  38. "╚═════════════════════════════════════════════════╝\r\n"
  39. "$";
  40.  
  41. #define    SPECLEN    60
  42.  
  43. char filespec [SPECLEN+1];
  44.  
  45. #define    NCOLS    SPECLEN+14
  46. #define    NROWS    7
  47.  
  48. char buffer [(NCOLS+1)*(NROWS+1)*2];
  49.  
  50. void main (void)
  51. {
  52.    long total_size;
  53.    struct ffblk ffblk;
  54.    int cshape, done, i, tally = 0, vmode, x, y;
  55.  
  56.    if ((vmode = v_getmode ()) != BW80 && vmode != C80 && vmode != MONO)
  57.        return;
  58.  
  59.    cshape = v_getshape ();
  60.    v_setshape (0x2000);         /* hide cursor */
  61.  
  62.    x = v_wherex ();
  63.    y = v_wherey ();
  64.  
  65.    v_screen (SCREEN_SAVE, 1, 1, NCOLS+1, NROWS+1, buffer);
  66.  
  67.    v_setattr (LIGHTGRAY << 4);
  68.    v_border (SINGLE_LINE, 1, 1, NCOLS, NROWS);
  69.    v_gotoxy (3, 1);
  70.    v_cputs ("╣ FTALLY v1.0 ■ Press ESC to exit. ╠");
  71.    v_shadow (1, 1, NCOLS, NROWS);
  72.    v_clear(2, 2, NCOLS-2, NROWS-2);
  73.  
  74.    v_gotoxy (2, 3);
  75.    v_cputs ("File Spec: ");
  76.  
  77.    while (1)
  78.    {
  79.       filespec [0] = '\0';
  80.  
  81.       if (getstr (filespec, SPECLEN) == ESC)
  82.       break;
  83.  
  84.       tally = 0;
  85.       total_size = 0;
  86.  
  87.       done = findfirst (filespec, &ffblk, 0);
  88.       while (!done)
  89.       {
  90.      tally++;
  91.      total_size += ffblk.ff_fsize;
  92.      done = findnext (&ffblk);
  93.       }
  94.  
  95.       v_gotoxy (2, 5);
  96.       v_cprintf ("Total files = %05d and size = %10lu", tally, total_size);
  97.       v_gotoxy (2, 6);
  98.       v_cprintf ("Total files = %04x and size = %0*lX", tally, 9,
  99.          total_size);
  100.  
  101.       v_gotoxy (13, 3);
  102.    }
  103.  
  104.    v_screen (SCREEN_RESTORE, 1, 1, NCOLS+1, NROWS+1, buffer);
  105.    v_gotoxy (x, y);
  106.    v_setshape (cshape);
  107. }
  108.  
  109. #ifndef INCL_FIND
  110. #include "find.C"
  111. #endif
  112.  
  113. #ifndef INCL_GETSTR
  114. #include "getstr.C"
  115. #endif
  116.  
  117. #ifndef INCL_KFETCH
  118. #include "kfetch.C"
  119. #endif
  120.  
  121. #ifndef INCL_SPRINTF
  122. #include "sprintf.C"
  123. #endif
  124.  
  125. #ifndef INCL_VBORDER
  126. #include "vborder.C"
  127. #endif
  128.  
  129. #ifndef INCL_VCPRINTF
  130. #include "vcprintf.C"
  131. #endif
  132.  
  133. #ifndef INCL_VCPUTS
  134. #include "vcputs.C"
  135. #endif
  136.  
  137. #ifndef INCL_VGETMODE
  138. #include "vgetmode.C"
  139. #endif
  140.  
  141. #ifndef INCL_VGETSHAPE
  142. #include "vgetshap.C"
  143. #endif
  144.  
  145. #ifndef INCL_VGOTOXY
  146. #include "vgotoxy.C"
  147. #endif
  148.  
  149. #ifndef INCL_VPAINT
  150. #include "vpaint.C"
  151. #endif
  152.  
  153. #ifndef INCL_VSCREEN
  154. #include "vscreen.C"
  155. #endif
  156.  
  157. #ifndef INCL_VSETATTR
  158. #include "vsetattr.C"
  159. #endif
  160.  
  161. #ifndef INCL_VSETSHAPE
  162. #include "vsetshape.C"
  163. #endif
  164.  
  165. #ifndef INCL_VSHADOW
  166. #include "vshadow.C"
  167. #endif
  168.  
  169. #ifndef INCL_VWHEREX
  170. #include "vwherex.C"
  171. #endif
  172.  
  173. #ifndef INCL_VWHEREY
  174. #include "vwherey.C"
  175. #endif